package com.lovo.lesson8.controller;


import com.lovo.lesson8.model.dto.StudentDTO;
import com.lovo.lesson8.result.ResponseResult;
import com.lovo.lesson8.service.StudentService;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author bdk
 * @since 2020-11-24
 */
@Api("学生信息的控制器")
@RestController
@RequestMapping("/students")
public class StudentController {
    @Resource
    private StudentService studentService;

    @ApiOperation("查询所有学生")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "当前页" ,example = "1"),
            @ApiImplicitParam(name = "size", value = "每页显示数" ,example = "5")
    })
    @GetMapping
    @ResponseResult
    public Object showAll( Integer page, Integer size){
        return studentService.selectAll(page,size);
    }

    @PostMapping
    @ResponseResult
    public Object save(@RequestBody @Valid StudentDTO studentDTO){
        studentService.saveStudent(studentDTO);
        return null;
    }

}

